<template>
<div class="">
    <div class="pr10">
        <div class="analyItem">
            <p class="analyItemTit tx-center">状态</p>
            <div class="analyItemCon">
                <span class="circlemark circlemark-lightRed">差</span>
            </div>
        </div>
    </div>
    <div class="thinScroll pr10" v-scrollHeight="84">
         <router-link tag="div" exact :to="{path:routerPath('personnelPersonnel'), query:{regionId: leftInfo.u_diqu}}" class="analyItem anItemBor" active-class="anItemBor-active" >
            <p class="analyItemTit tx-center">内部</p>
            <div class="analyItemCon">
                <p class="col-md-4">
                    <span class="pr8 cLightGray">产出比</span>
                    <span>{{peopleMent.toFixed(2)}}%</span>
                </p>
                <p class="col-md-4">
                    <span class="pr8 cLightGray">标准</span>
                    <span>100%</span>
                </p>
                <p class="col-md-4">
                    <span class="pr8 cLightGray">差额</span>
                    <span>{{(100 - peopleMent).toFixed(2)}}%</span>
                </p>
                <span v-if="peopleMent >= 100" class="circlemark circlemark-green">优</span>
                <span v-else-if="peopleMent < 100 &&  peopleMent >= 80" class="circlemark circlemark-lightGreen">良</span>
                <span v-else-if="peopleMent < 80 &&  peopleMent >= 60 " class="circlemark circlemark-yellow">中</span>
                <span v-else class="circlemark circlemark-lightRed">差</span>
            </div>
        </router-link>
        <div class="analyItem">
            <p class="analyItemTit tx-center">项目经理</p>
            <div class="analyItemCon">
                <p class="col-md-4">
                    <span class="pr8 cLightGray">人数</span>
                    <span>{{termNumber.perNum}}</span>
                </p>
                <p class="col-md-4">
                    <span class="pr8 cLightGray">退单</span>
                    <span>{{termNumber.td}}</span>
                </p>
                <p class="col-md-4">
                    <span class="pr8 cLightGray">拒单</span>
                    <span>{{termNumber.jd}}</span>
                </p>
                <p class="col-md-4">
                    <span class="pr8 cLightGray">未接</span>
                    <span>{{termNumber.Norder}}</span>
                </p>
            </div>
        </div>
        <div class="analyItem">
            <p class="analyItemTit tx-center">材料商</p>
            <div class="analyItemCon">
                <p class="col-md-4">
                    <span class="pr8 cLightGray">人数</span>
                    <span>{{count}}</span>
                </p>
            </div>
        </div>
        <div class="analyItem">
            <p class="analyItemTit tx-center">工人</p>
            <div class="analyItemCon">
                <p class="col-md-4">
                    <span class="pr8 cLightGray">人数</span>
                    <span>{{workerCount}}</span>
                </p>
            </div>
        </div>
    </div>
    <div class="pr10">
        <router-link tag="div" :to="routerPath('personnelProcessing')" class="analyItem anItemBor" active-class="anItemBor-active">
            <p class="analyItemTit tx-center">处理</p>
            <div class="analyItemCon">

            </div>
        </router-link>
    </div>
</div>
</template>
<script>
import { getUserCount, getWorkerCountByAreaId, findPmManagerByAreaId, getDivisionPersonnel } from '../Resources/Api'
import { mapGetters } from 'vuex'
export default {
    data () {
        return {
            parmasExample: {
                name: '',
                age: ''
            },
            peopleAll: {},
            count: 0, // 材料人数
            workerCount: 0, // 工人联盟人数
            termNumber: {}, // 项目经李人数
            peopleMent: 0
        }
    },
    created () {
        this.getUserCount() // 材料人数
        this.getWorkerCountByAreaId() // 工人联盟人数
        this.findPmManagerByAreaId() // 项目经理人数
        this.getDivisionPersonnel() // renshi
    },
    computed: {
        ...mapGetters(['userInfo', 'leftInfo'])
    },
    methods: {
        findPmManagerByAreaId () {
            findPmManagerByAreaId({
                uid: this.leftInfo.u_diqu
            }).then(res => {
                if (res.data.StatusCode === 0) {
                    this.termNumber = res.data.Body
                }
            }).catch(err => {
                console.log(err)
            })
        },
        getWorkerCountByAreaId () {
            getWorkerCountByAreaId({
                areaId: this.leftInfo.u_diqu
            }).then(res => {
                if (res.data.StatusCode === 1) {
                    this.workerCount = res.data.Body.workerCount
                }
            }).catch(err => {
                console.log(err)
            })
        },
        getDivisionPersonnel () {
            var obj = {
                diqu: this.leftInfo.u_diqu
            }
            getDivisionPersonnel(obj).then(res => {
                if (res.data.StatusCode === 0) {
                    this.peopleAll = res.data.Body
                    this.peopleMent = this.peopleAll.sumCompletionMoney === 0 ? 0 : (this.peopleAll.sumCompletionMoney / (this.peopleAll.sumGreatMore * 10000)) * 100
                }
            }).catch(err => {
                console.log(err)
            })
        },
        getUserCount () {
            getUserCount({
                dqid: this.leftInfo.u_diqu
            }).then(res => {
                if (res.data.statusCode === 0) {
                    this.count = res.data.body.count
                }
            }).catch(err => {
                console.log(err)
            })
        },
        // 路由跳转路径拼接
        routerPath (path) {
            return this.$route.matched[1].path + '/' + path
        },
        // 直接进行路由跳转路径
        routerPush (path) {
            this.$router.push(this.$route.matched[1].path + '/' + path)
        }
    },
    watch: {
        leftInfo () {
            this.getDivisionPersonnel()
            this.getUserCount() // 材料人数
            this.getWorkerCountByAreaId() // 工人联盟人数
            this.findPmManagerByAreaId() // 项目经理人数
        }
    }
}
</script>
